package linked.pratice;

import linked.Node;
import linked.DoubleLinkedListADT;

public class Sort {
    public static void main(String[] args) {
        DoubleLinkedListADT<Integer> link = new DoubleLinkedListADT<>();
        Node<Integer> node04 = new Node<>(4);
        Node<Integer> node01 = new Node<>(1);
        Node<Integer> node02 = new Node<>(2);
        Node<Integer> node03 = new Node<>(3);
        Node<Integer> node05 = new Node<>(5);

        link.addLast(node01).addLast(node02).addLast(node03).addFirst(node04).addLast(node05);

//        sort(link);

        link.showList();

    }

    public static void sort(DoubleLinkedListADT list){
        //冒泡
        Node out=list.getTail();
        Node inner=list.head;
        while (out.prev!=list.head){
            while (inner.next!=out){
                if (inner.data>inner.next.data){
                    list.swap(inner,inner.next);
                }
                inner=inner.next;
            }
            out=out.prev;
        }

    }
}
